<!--
  功能说明：基础分页组件，接收总数与当前分页信息并触发翻页事件。
-->
<template>
  <div class="pagination" v-if="total > pageSize">
    <button :disabled="page===1" @click="$emit('change', page-1)">上一页</button>
    <span>第 {{ page }} / {{ totalPages }} 页</span>
    <button :disabled="page===totalPages" @click="$emit('change', page+1)">下一页</button>
  </div>
  
</template>

<script>
export default {
  name: 'BasePagination',
  props: {
    total: { type: Number, required: true },
    page: { type: Number, required: true },
    pageSize: { type: Number, required: true }
  },
  computed: {
    totalPages() {
      return Math.ceil(this.total / this.pageSize)
    }
  }
}
</script>

<style>
.pagination { display: flex; gap: 8px; align-items: center; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
</style>